<?php

namespace App\Services\Business;

use App\Services\Business\Business\BusinessLogic;

/**
 * 业务服务层
 * Class Business
 * @package App\Services\Business
 */
class Business
{
    /**
     * 添加业务
     */
    public function add($data)
    {
        if (empty($data)) {
            return null_data($data,"参数不能为空！");
        }
        //$data = init_array($data,["company_name", "phone_name", "address", "phone", "code", "company_image"]);        
        ValidateBusiness::checkValidate($data, ["company_name", "phone_name", "address", "phone", "code"]);
        return (new BusinessLogic())->add($data);
    }

    /**
     * 删除业务
     * @param $data
     * @return array
     * @throws \App\Exceptions\RequestFailException
     */
    public function delete($data)
    {
        if (empty($data)) {
            return null_data($data,"参数不能为空！");
        }
        $data = init_array($data,['id'=>" "]);
        ValidateBusiness::checkValidate($data,['id']);

        return (new BusinessLogic())->delete($data);
    }

    /**
     * 获取业务列表
     * @return mixed
     */
    public function businessList($data)
    {
        $data = init_array($data,["page"=>1,"listRows"=>15]);
        return (new BusinessLogic())->businessList($data);
    }

}